package com.ybwh.springboot2.mapstruct;

import org.mapstruct.Mapper;
import org.mapstruct.Named;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;

/**
 * <p>
 *  注意  componentModel  要统一
 * </p>
 *
 * @author fanbeibei
 * @version 1.0.0
 * @date 2022/3/13 13:36
 */

@Named("MyConvert")
@Mapper(componentModel = "default", unmappedSourcePolicy = ReportingPolicy.WARN, unmappedTargetPolicy = ReportingPolicy.WARN)
public interface MyConvert {
    MyConvert INSTANCE = Mappers.getMapper(MyConvert.class);

    @Named("myTransformation2")// or your custom @Qualifier annotation
    default String customConveter(Pos pos) {
        if (null == pos) {
            return null;
        }
        return pos.getName();
    }
}
